package com.yax.mickey.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yax.mickey.entity.OrderDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author yax
* @description 针对表【order_detail(订单详情信息表)】的数据库操作Mapper
* @createDate 2024-05-27 09:03:45
* @Entity com.yax.mickey.entity.OrderDetail
*/
@Mapper
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {

    @Select("select * from `order_detail`")
    List<OrderDetail> getAllOrderDetail();

    @Select("select * from `order_detail` where order_id = #{orderId}")
    List<OrderDetail> getOrderDetailByOrderId(int orderId);

    @Insert("insert into `order_detail` (order_detail_id, order_id, product_id, quantity, unit_amount) \n" +
            "values (#{orderDetailId}, #{orderId}, #{productId}, #{quantity}, #{unitAmount});")
    Integer addOrderDetail(OrderDetail orderDetail);

    @Update("update `order_detail` set order_id = #{orderId}, product_id = #{productId}, quantity = #{quantity}, unit_amount = #{unitAmount} where order_detail_id = #{orderDetailId}")
    void updateOrderDetail(OrderDetail orderDetail);

    @Delete("delete from `order_detail` where order_detail_id = #{orderDetailId}")
    void deleteOrderDetail(OrderDetail orderDetail);
}




